xen/multicall: Rework arch multicall handling
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 26 Jan 2015 14:30:43 +0000 (14:30 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 6 Sep 2016 12:34:55 +0000 (13:34 +0100)
The x86 multicall handling was previously some very hairy inline assembly, and
is hard to follow and maintain.

Replace the existing do_multicall_call() with arch_do_multicall_call().  The
x86 side needs to handle both compat and non-compat calls, so pass the full
multicall state, rather than just the multicall_entry sub-structure.

On the ARM side, alter the prototype to match, but there is no resulting
functional change.  On the x86 side, the implementation is now in plain C.

This allows the removal of both asm/multicall.h header files.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/arm/traps.c
xen/arch/x86/hypercall.c
xen/common/multicall.c
xen/include/asm-arm/multicall.h [deleted file]
xen/include/asm-x86/multicall.h [deleted file]
xen/include/xen/multicall.h

index 683bcb28f54aa84a0318b53d3d34406f8e10ed09..9353ee73b9b63ea09918ac1ad6e7e969fbea1105 100644 (file)
@@ -1516,8 +1516,9 @@ static bool_t check_multicall_32bit_clean(struct multicall_entry *multi)
     return true;
 }
 
-void do_multicall_call(struct multicall_entry *multi)
+void arch_do_multicall_call(struct mc_state *state)
 {
+    struct multicall_entry *multi = &state->call;
     arm_hypercall_fn_t call = NULL;
 
     if ( multi->op >= ARRAY_SIZE(arm_hypercall_table) )
index faff2604c76a86477d7d1a1bf037f081f5e06007..b814c0be521db216b967e4a8a80f99a869f107c2 100644 (file)
@@ -340,6 +340,34 @@ void pv_hypercall(struct cpu_user_regs *regs)
     perfc_incr(hypercalls);
 }
 
+void arch_do_multicall_call(struct mc_state *state)
+{
+    if ( !is_pv_32bit_vcpu(current) )
+    {
+        struct multicall_entry *call = &state->call;
+
+        if ( (call->op < NR_hypercalls) && hypercall_table[call->op] )
+            call->result = hypercall_table[call->op](
+                call->args[0], call->args[1], call->args[2],
+                call->args[3], call->args[4], call->args[5]);
+        else
+            call->result = -ENOSYS;
+    }
+#ifdef CONFIG_COMPAT
+    else
+    {
+        struct compat_multicall_entry *call = &state->compat_call;
+
+        if ( (call->op < NR_hypercalls) && compat_hypercall_table[call->op] )
+            call->result = compat_hypercall_table[call->op](
+                call->args[0], call->args[1], call->args[2],
+                call->args[3], call->args[4], call->args[5]);
+        else
+            call->result = -ENOSYS;
+    }
+#endif
+}
+
 /*
  * Local variables:
  * mode: C
index 21661ee4f8cb7ae168e611eae0d23aba9729cc98..524c9bf090608d0c0e45ec6d7e2d6f571f383bb8 100644 (file)
@@ -63,7 +63,7 @@ do_multicall(
 
         trace_multicall_call(&mcs->call);
 
-        do_multicall_call(&mcs->call);
+        arch_do_multicall_call(mcs);
 
 #ifndef NDEBUG
         {
diff --git a/xen/include/asm-arm/multicall.h b/xen/include/asm-arm/multicall.h
deleted file mode 100644 (file)
index b959262..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __ASM_ARM_MULTICALL_H__
-#define __ASM_ARM_MULTICALL_H__
-
-extern void do_multicall_call(struct multicall_entry *call);
-
-#endif /* __ASM_ARM_MULTICALL_H__ */
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/asm-x86/multicall.h b/xen/include/asm-x86/multicall.h
deleted file mode 100644 (file)
index fcd0ea5..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/******************************************************************************
- * asm-x86/multicall.h
- */
-
-#ifndef __ASM_X86_MULTICALL_H__
-#define __ASM_X86_MULTICALL_H__
-
-#include <xen/errno.h>
-
-#define do_multicall_call(_call)                             \
-    do {                                                     \
-        __asm__ __volatile__ (                               \
-            "    movq  %c1(%0),%%rax; "                      \
-            "    leaq  hypercall_table(%%rip),%%rdi; "       \
-            "    cmpq  $("STR(NR_hypercalls)"),%%rax; "      \
-            "    jae   2f; "                                 \
-            "    movq  (%%rdi,%%rax,8),%%rax; "              \
-            "    movq  %c2+0*%c3(%0),%%rdi; "                \
-            "    movq  %c2+1*%c3(%0),%%rsi; "                \
-            "    movq  %c2+2*%c3(%0),%%rdx; "                \
-            "    movq  %c2+3*%c3(%0),%%rcx; "                \
-            "    movq  %c2+4*%c3(%0),%%r8; "                 \
-            "    movq  %c2+5*%c3(%0),%%r9; "                 \
-            "    callq *%%rax; "                             \
-            "1:  movq  %%rax,%c4(%0)\n"                      \
-            ".section .fixup,\"ax\"\n"                       \
-            "2:  movq  %5,%%rax\n"                           \
-            "    jmp   1b\n"                                 \
-            ".previous\n"                                    \
-            :                                                \
-            : "b" (_call),                                   \
-              "i" (offsetof(__typeof__(*_call), op)),        \
-              "i" (offsetof(__typeof__(*_call), args)),      \
-              "i" (sizeof(*(_call)->args)),                  \
-              "i" (offsetof(__typeof__(*_call), result)),    \
-              "i" (-ENOSYS)                                  \
-              /* all the caller-saves registers */           \
-            : "rax", "rcx", "rdx", "rsi", "rdi",             \
-              "r8",  "r9",  "r10", "r11" );                  \
-    } while ( 0 )
-
-#define compat_multicall_call(_call)                         \
-        __asm__ __volatile__ (                               \
-            "    movl  %c1(%0),%%eax; "                      \
-            "    leaq  compat_hypercall_table(%%rip),%%rdi; "\
-            "    cmpl  $("STR(NR_hypercalls)"),%%eax; "      \
-            "    jae   2f; "                                 \
-            "    movq  (%%rdi,%%rax,8),%%rax; "              \
-            "    movl  %c2+0*%c3(%0),%%edi; "                \
-            "    movl  %c2+1*%c3(%0),%%esi; "                \
-            "    movl  %c2+2*%c3(%0),%%edx; "                \
-            "    movl  %c2+3*%c3(%0),%%ecx; "                \
-            "    movl  %c2+4*%c3(%0),%%r8d; "                \
-            "    movl  %c2+5*%c3(%0),%%r9d; "                \
-            "    callq *%%rax; "                             \
-            "1:  movl  %%eax,%c4(%0)\n"                      \
-            ".section .fixup,\"ax\"\n"                       \
-            "2:  movl  %5,%%eax\n"                           \
-            "    jmp   1b\n"                                 \
-            ".previous\n"                                    \
-            :                                                \
-            : "b" (_call),                                   \
-              "i" (offsetof(__typeof__(*_call), op)),        \
-              "i" (offsetof(__typeof__(*_call), args)),      \
-              "i" (sizeof(*(_call)->args)),                  \
-              "i" (offsetof(__typeof__(*_call), result)),    \
-              "i" (-ENOSYS)                                  \
-              /* all the caller-saves registers */           \
-            : "rax", "rcx", "rdx", "rsi", "rdi",             \
-              "r8",  "r9",  "r10", "r11" )                   \
-
-#endif /* __ASM_X86_MULTICALL_H__ */
index 0e8d8bb0aef3b599d3bcef367654bf4e481c2cf8..fff15ebf2c015a814376b34c8e4e29315b13688e 100644 (file)
@@ -6,7 +6,6 @@
 #define __XEN_MULTICALL_H__
 
 #include <xen/percpu.h>
-#include <asm/multicall.h>
 #ifdef CONFIG_COMPAT
 #include <compat/xen.h>
 #endif
@@ -25,4 +24,6 @@ struct mc_state {
     };
 };
 
+void arch_do_multicall_call(struct mc_state *mc);
+
 #endif /* __XEN_MULTICALL_H__ */